import actionType from "../action_type";

export const addCount = number => ({
  type: actionType.COUNT_ADD,
  data: number
});

export const minusCount = number => ({
  type: actionType.COUNT_MINUS,
  data: number
});

export const reducer = (state, action) => {
  switch (action.type) {
    case actionType.COUNT_ADD:
      return { ...state, count: state.count + 1 };
    case actionType.COUNT_MINUS:
      return { ...state, count: state.count - 1 };
    default:
      return state;
  }
};
